package com.cskaoyan.com.collection.collection;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;

public class DemoCollection9 {
    public static void main(String[] args) {

        Collection<String> collection = new LinkedList<>();
        collection.add("zs");
        collection.add("ls");
        collection.add("wu");
        collection.add("zl");


        Iterator<String> iterator = collection.iterator();

        // 想删除所有的collection容器中存储的zs
        while (iterator.hasNext()){
            String next = iterator.next();
            if (next.equals("zs")){
                iterator.remove();
            }
        }


        // Iterator 主要用来做遍历的(hasNext, next), (remove: 用在我们遍历的某个数据不符合我们预期)


    }
}
